<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			
			function sum(){
				var arr =String(prompt("请输入一个正整数："));
				var a = 0;
					for(j=0;j<arr.length;j++){
						a += Number(arr[j]);
					}
					return a;
				}
			var b = sum();
			document.write("输入的正整数各位上的和为："+b);
		</script>
	</body>
</html>
